<template>
	<view id="list">
		<uni-list>
			<uni-list-item v-for="(i_, i) in list" :key="i" :title="i_.title" :note="i_.createTime" link
				:to="'/pages/mine/sourceInfo?id='+i_.id" :clickable="true" :thumb="i_.img" thumb-size="lg"
				rightText="点击查看">
			</uni-list-item>
		</uni-list>

		<div id="page">
			<uni-pagination @change="sourceList()" :pageSize="parameter.pageSize" :total="parameter.total"
				:current="parameter.pageNum" :value="parameter.pageNum" />
		</div>
	</view>
</template>
<script>
	import {
		type,
		list
	} from '@/api/source.js'

	export default {
		data() {
			return {
				parameter: {
					typeId: null,
					title: null,
					// 数据总量
					total: 0,
					// 每页数据量
					pageSize: 20,
					// 当前页
					pageNum: 1
				},
				list: []
			};
		},
		onLoad(option) {
			if (option.type) {
				this.parameter.typeId = option.type;
				this.sourceList();

				uni.setNavigationBarTitle({
					title: option.name
				})
			}
		},
		methods: {
			sourceList() {
				list(this.parameter).then(res => {
					if (res.code == 200) {
						this.parameter.total = res.total
						this.list = res.rows
					}
				})
			}
		}
	}
</script>
<style lang="scss">
	#list {
		padding: 2px;
	}
</style>